package com.sa.dto;

/**
 * @author wangxiaohui
 * @date 2023/6/13 14:18
 */
public class Result<T> {

    private String code;

    private String message;

    private T data;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static Result ok(Object data) {
        Result<Object> tResult = new Result<>();
        tResult.setData(data);
        tResult.setCode("1");
        tResult.setMessage("成功");
        return tResult;
    }

    public static Result error() {
        Result result = new Result<>();
        result.setCode("0");
        result.setMessage("失败");
        result.setData(null);
        return result;
    }
}
